#!/usr/bin/python
#coding:utf-8
'''
字符串工具类
'''

import re

def getReg(context,start,end):
    '''
    字符串内容正则提取，已第一个end字符结束位置截取
    context: 字符内容
    start: 开始字符串
    end: 结束字符串
    return list
    '''
    valueList=re.findall(start+"(.+?)"+end,context)
    realList=[]
    if len(valueList)>0:

        for one in valueList:
            print(start+one+end)
            realList.append(start+one+end)
    return valueList


def getRegMore(context,start,end):
    '''
    贪心字符串正字匹配，已最后一个end字符结尾位置截取
    context: 字符串
    start: 开始字符串
    end: 结束字符串
    return list
    '''
    valueList=re.findall(start+"(.+)"+end,context)
    realList=[]
    if len(valueList)>0:

        for one in valueList:
            print(start+one+end)
            realList.append(start+one+end)
    return valueList

def str_insert(str_origin, pos, str_add):
    '''
    字符串传入
    str_origin:原始字符串
    post：从1开始下标
    str_add：添加的字符串
    '''
    str_list = list(str_origin)    # 字符串转list
    str_list.insert(pos, str_add)  # 在指定位置插入字符串
    str_out = ''.join(str_list)    # 空字符连接
    return  str_out